package com.atguigu.stgy.admin.controller;

import com.atguigu.stgy.admin.service.LeaseAgreementService;
import com.atguigu.stgy.model.dto.AgreementSearchDTO;
import com.atguigu.stgy.model.entity.LeaseAgreement;
import com.atguigu.stgy.model.result.R;
import com.atguigu.stgy.model.vo.AgreementVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


/**
 * 租约信息表(lease_agreement)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/admin/agreement")
public class LeaseAgreementController {
    /**
     * 服务对象
     */
    @Resource
    private LeaseAgreementService leaseAgreementService;
    //
    @Operation(summary = "新增或更新租约信息")
    @PostMapping("saveOrUpdate")
    public R saveOrUpdate(@RequestBody LeaseAgreement leaseAgreement){
        leaseAgreementService.saveOrUpdate(leaseAgreement);
        return R.ok();
    }

    ///admin/agreement/page?current=1&size=10
    @Operation(summary = "条件查询租约分页列表")
    @GetMapping("page")
    public R pageItem(AgreementSearchDTO searchDTO){
        Page<AgreementVO> page = leaseAgreementService.pageItem(searchDTO);
        return R.ok(page);
    }


}
